package com.wyix;

import com.wyix.domain.Pet;
import com.wyix.service.PetService;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * @author wangdx
 * @since 2025/8/5
 */
public class PetServiceTest {

    // com.example.Main.java
    public static void main(String[] args) {
        List<Pet> pets = Arrays.asList(
                new Pet("小白", 2, "狗", true),
                new Pet("雪球", 1, "兔子", false),
                new Pet("咪咪", 3, "猫", true),
                new Pet("大黄", 2, "狗", true)
        );

        PetService service = new PetService();

        // 筛选已接种疫苗的宠物
        List<Pet> vaccinatedPets = service.filterVaccinatedPets1(pets);
//        System.out.println("已接种疫苗的宠物：" + vaccinatedPets);
        System.out.println("--------已接种疫苗的宠物----------");
        vaccinatedPets.forEach(System.out::println);

        // 按年龄排序
        List<Pet> sortedByAge = service.sortPetsByAge(pets);
        System.out.println("--------按年龄升序排序----------");
        sortedByAge.forEach(System.out::println);

        // 按年龄倒序排序
        List<Pet> sortedByAgeDesc = service.sortPetsByAgeDesc(pets);
        System.out.println("--------按年龄倒序排序----------");
        sortedByAgeDesc.forEach(System.out::println);

        // 统计类型数量
        Map<String, Long> typeCount = service.countPetsByType(pets);
        System.out.println("--------宠物类型统计----------");
        typeCount.forEach((type, count) -> System.out.println(type + ": " + count));
    }
}
